using System;

namespace EventBehaviorTree
{
    [Serializable]
    public class RootNode : Container<ContainerMode>
    {
        private bool _isWorking;
        public RootNode() { _isWorking = false; }
        public override void NodeEvent(NodeMessage nodeMessage)
        {
            switch (nodeMessage)
            {
                case NodeMessage.Start:
                    if (_isWorking) return;
                    _subNodes[0].NodeEvent(nodeMessage);
                    _isWorking = true;
                    return;
                case NodeMessage.COMMAND_Stop:
                    StopAllSubNodes();
                    _isWorking = false;
                    return;
                case NodeMessage.REQUEST_Abort:
                    StopAllSubNodes();
                    _isWorking = false;
                    return;
                default:
                    return;
            }
        }
    }
}
